package com.chaopei.constructor;

/**
 * @Author Corday 天涯
 * @Date 2022/3/4 14:24
 */
public class TestMain {
    public static void main(String[] args) {
        //父类指向子类
        Flower flower = new Rose("玫瑰", 30, "白色", "好多刺", "清香");
        //父类直接创建对象
        Flower fw = new Flower("百合",50,"白色");
        String name = flower.getName();
//        //将父类的引用对象强转为子类对象
        Rose rose = (Rose)flower;
        //将有引用关系的子类对象直接赋值给父类的对象
        Flower temp = rose;
        String sting = rose.getSting();
        System.out.println("玫瑰有:"+sting);
        System.out.println("-------------");
        //不能强转,因为父类没有指向子类
       // Rose rs = (Rose)fw;
        //System.out.println(rs.getSting());
        System.out.println("------不同的构造创建对象------");
        Animal animal = new Animal("二哈",98);
        System.out.println(animal.getNick()+animal.getWeight());
        Animal animal1 = new Animal("德牧",100,"犬类");
        System.out.println(animal1.getNick()+animal1.getWeight()+animal1.getType());
    }//main
}
